import { RouteRecordRaw } from 'vue-router';

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    redirect: '/home',
    component: () => import('layouts/MainLayout.vue'),
    children: [
      {
        path: 'home',
        component: () => import('pages/Index.vue'),
      },
      {
        path: 'orders',
        component: () => import('pages/Orders.vue'),
        meta: {
          roles: ['user'],
        },
      },
      {
        path: 'order_detail',
        component: () => import('pages/OrderDetail.vue'),
        name: 'Detail',
        meta: {
          roles: ['user', 'admin'],
        },
      },
      {
        path: 'user',
        component: () => import('pages/User.vue'),
        meta: {
          roles: ['user'],
        },
      },
      {
        path: 'add_order',
        component: () => import('pages/AddOrder.vue'),
        meta: {
          roles: ['user'],
        },
      },
      {
        path: 'order_manage',
        component: () => import('pages/OrderManage.vue'),
        meta: {
          roles: ['admin'],
        },
      },
      {
        path: 'staff_manage',
        component: () => import('pages/StaffManage.vue'),
        meta: {
          roles: ['admin'],
        },
      },
      {
        path: 'truck_manage',
        component: () => import('pages/TruckManage.vue'),
        meta: {
          roles: ['admin'],
        },
      },
    ],
  },
  {
    path: '/auth',
    redirect: '/auth/login',
    component: () => import('layouts/AuthLayout.vue'),
    meta: {
      roles: ['guest'],
    },
    children: [
      {
        path: 'login',
        component: () => import('pages/Login.vue'),
      },
      {
        path: 'register',
        component: () => import('pages/Register.vue'),
      },
    ],
  },
  {
    path: '/:catchAll(.*)*',
    component: () => import('pages/Error404.vue'),
  },
];

export default routes;
